package org.jmetrix.throughput;

import org.jmetrix.group.AbstractGroupMeasurement;

import java.util.concurrent.TimeUnit;

/**
 * @author Konstantin Kuzmin
 * @version $Revision$
 * @since 05.09.12
 */
public class ThroughputEvent extends AbstractGroupMeasurement<Long> {
    private final long eventNanoTime;
    private final String name;
    private final TimeUnit timeUnit;

    public ThroughputEvent(String name) {
        this(name, TimeUnit.SECONDS);
    }

    public ThroughputEvent(String name, TimeUnit timeUnit) {
        this.name = name;
        this.eventNanoTime = getTime();
        this.timeUnit = timeUnit;
    }

    public static long getTime() {
        return System.nanoTime();
    }

    @Override
    public Long getValue() {
        return eventNanoTime;
    }

    public TimeUnit getTimeUnit() {
        return timeUnit;
    }
}
